trigger AptiIntegration_OnOpportunity on Opportunity (after update) {
	set<string> aptiIdStatusDetail = new set<string>();
	for(Opportunity tempOpp : Trigger.new) {
		if(tempOpp.APTI_ID__c != null && tempOpp.RecordTypeId == Schema.sObjectType.Opportunity.getRecordTypeInfosByName().get('West - Student Application').getRecordTypeId()) {
			if(tempOpp.Status_Detail_APTI__c != Trigger.oldMap.get(tempOpp.id).Status_Detail_APTI__c ) {
				if(tempOpp.StageName == 'Declined' || tempOpp.StageName == 'No Further Action') {
					aptiIdStatusDetail.add(tempOpp.Id + '-'+ tempOpp.APTI_ID__c + '+' + tempOpp.Status_Detail_APTI__c );
				}
			}
			if(tempOpp.StageName == 'Registered' && tempOpp.StageName != Trigger.oldMap.get(tempOpp.id).StageName) {
				aptiIdStatusDetail.add(tempOpp.Id + '-'+ tempOpp.APTI_ID__c + '+' + tempOpp.StageName );
			}
		}		
	}
	
	if(aptiIdStatusDetail.size() !=0)
		AptiIntegration_DataMap.doCallOutAptiService(aptiIdStatusDetail);
}